Part Number Hot Search : 
3130EZ PESD5 BD6222 A1715 29LV010 PESD5 PP3500SC J100078
Product Description
Full Text Search
 

To Download AN1809 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN1809/0205 1/8 rev. 2 AN1809 application note str71x adc driving an analog keyboard introduction this application note gives an example of how to use the str71x analog to digital converter (adc) to read input from an analog keyboar d. the purpose is to decode a number of keys through only one analog i/o port pin, this has the advantage of reducing the number of pins used compared to a traditional matrix keyboard wh ich requires a large number of i/o port pins. 1
2/8 str71x adc driving an analog keyboard 1 hardware configuration to reach the goal of this application note we need to connect an analog keyboard to one of the analog inputs of the str71x adc. when a key is pressed, the voltage at the adc input is given by the activated voltage divider. this analog voltage is converted by the adc and the digital value is used to determine which switch is closed. figure 1. str71x adc and analog keyboard configuration 1.1 str71x adc the str71x analog to digital converter is a 12-bit sigma-delta converter with an input range between 0 and 2.5v. it has up to 4 multiplexed analog input channels. it offers two conversion modes: round-robin : this repeats the conversion process for each of the four channels continuously in turn. single channel : this converts only the selected analog input. enabling or disabling the converter is done by setting or clearing the adc_en bit in the pcu_bootcr register. the str71x adc provides four 16-bit data regi sters to store the conversion result for each channel. the availability of the conversion result in the data register is shown by the four da[3:0] flags in the control/ status register (adc_csr). an interrupt is generated depending on the conversion mode, to confirm the end of conver - sion. in single channel mode, an interrupt is generated if the interrupt bit and data available flag in the adc_csr are set, corresponding to the selected channel. in round robin mode, an str71x v3.3 adc ainx avss avdd vss r 0 r 1 r 13 r 14 r up key0 key1 key14 key15 vdd vss keyboard 2.5v 2
3/8 str71x adc driving an analog keyboard interrupt will be generated if all interrupt bits and all data available flags in the adc_csr are set. the clock configuration of the str71x converter is used to define the oversampling fre - quency which clocks the modulato r of the sigma-delta converte r. this frequency is pro - grammed basing on the f pclk2 frequency and the sampling frequency. the oversampling rate is obtained by configuring the 12-b it value of the prescaler register. the value to write in the converter prescaler register is: adc_cpr = (rccu_frequencyvalue(rccu_pclk)/(adc12_clk*512*8)) the real factor, by which the input frequency wi ll be multiplied to produce the oversampling frequency, is twice the pr escaler register value. 1.2 i/o configuration the str71x analog to digital converter provides four analog input pins for connecting dif - ferent analog signals. these pins are internal ly multiplexed to use the same sigma-delta logic. depending on the conversion mode (continuous or single channel), you can use either the four analog inputs or only one selected pin. if you are using the single channel mode, you can select a pin by writing the channel number in the a[1:0] bits in the control status reg - ister(adc_csr). these pins are mapped on the pins of gpio port 1(p1.1, p1.2, p1.3, p1.4). to use the port pins as analog inputs, you must configure them as high impedance-analog in - puts by writing the appropriate values in to the pc0, pc1 and pc2 registers of gpio port 1. 1.3 analog keyboard the analog keyboard is formed by a number of keys connected to resistive dividers; with a pull-up resistor. in the analog keyboard each key is associated with a voltage. r0-->r14: serial resistors through which keys will be connected to the analog input. r 0 r 1 r 13 r 14 r up key0 key1 key14 key15 keyboard to v dd to analog input v key to v ss
4/8 str71x adc driving an analog keyboard r up : the pull-up resistor by which the v key is maintained to vdd when no key is pressed. the associated voltage of the pressed key is given by: if more than one key is pressed at the same time, the key detected will be the next key in the chain closest to the adc input. this means that the key recognition is managed by priority. 1.3.1 key recognition the number of keys which can be detected depends on the tolerance of the resistors used. this mean that we must take a voltage range corresponding to each key when we convert the result. the resistor value and the equivalent voltage of each key are given by the following table. r up =1200 ? table 1. key decision key resistor ( ? ) voltage ( mv ) key resistor ( ? ) voltage ( mv ) 0 0 0 8 220 1121 1 56 111 9 270 1273 2 68 234 a 390 1442 3 82 366 b 560 1616 4 100 507 c 820 1788 5 120 654 d 1200 1946 6 150 810 e 1800 2084 7 180 966 f 2800 2200 v key i v dd v ss ? () r j j 0 = i 1 ? r up r j j 0 = i 1 ? + --------------------------------------------------- - =
5/8 str71x adc driving an analog keyboard 2 software configuration this software example manages the str71x adc configuration, and the key recognition using the adc software library. after configuring the analog input as a high impedance analog input, the str71x adc has to be enabled by setting the adc_en bit in the pcu_bootcr register. th is action is followed by selecting the single channel conversion mode and the channel to be converted by setting the axt bit and writing the channel number in the a[1:0] bits in the control status register (adc_csr). next, the prescaler has to be configured. waiting for the availability of data in the corresponding data register is done by loopi ng on the data available flag (dan) in adc_csr register. after that, we can get the conversion result which will be calibrated. the next step is the key recognition. this part of the software consists of testing if the conver - sion result belongs to the range of the value of each key voltage. this range is defined by the lower voltage (min [key]) and the higher volt age (max [key]) that are considered as corre - sponding to the typical voltage of the key (val [key]). this range is due to the resistor toler - ance. once the pressed key is recognized, its number is shown on four leds connected to gpio port 0 pins. the main program is given by the next flowchart.
6/8 str71x adc driving an analog keyboard figure 2. main program flowchart using adc software library the key recognition routine is shown in the next flowchart with: max[key]: higher voltage of the range corresponding to the typical voltage of the key. min[key]: lower voltage of the range corresponding to the typical voltage of the key. val [key]: typical voltage. end configure the adc input ainn as high impedance analog input start the converson configure the prescaler select the channel select single channel mode get conversion result stop the converter da[n]=1? yes no adc12_conversionstart(); adc12_channelselect(adc12_channel1); while (adc12_flagstatus (adc12_da1) == reset); { ... ... } adc12_prescalerconfig(500); adc12_modeconfig (adc12_single); gpio_config (gpio1, 0x0002, gpio_hi_ain_tri); con_res = adc12_conversionvalue(adc12_channel1); adc12_conversionstop(); recognize the key //see the key recognition flowchart calibrate the conversion result //see the key recognition flowchart begin yes no initialize the adc registers adc12_init();
7/8 str71x adc driving an analog keyboard figure 3. key recognition x = conversion result x = val[0] min[2] =< x =< max[2] min[1] =< x =< max[1] min[0] =< x =< max[0] x = val[2.5] x = val[1] x = val[2] x = val[e] x = val[d] min[f] =< x =< max[f] min[e] =< x =< max[e] min[d] =< x =< max[d] return the typical value of the key begin x = val[f]
8/8 str71x adc driving an analog keyboard ?the present note which is for guidance only aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connection with their products.? information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the co nsequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without express written approval of stmicroelectro nics. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners ? 2005 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia ? belgium - brazil - canada - china ? czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN1809

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X